/**
 *
 * 选择日期的组件
 *
 * */
import {ICellInputProps} from "@/biz-components/claim-items/components-v2/cell-input/ICellInputProps";
import {DatePicker} from "antd";
import moment from "moment";

export interface SelectDateExtraProps {

}

/**
 * value 是字符串 ‘YYYY-MM-DD’ 或者空字符串
 * */
export function SelectDate(props: SelectDateExtraProps & ICellInputProps<string>) {
	const {value, onChange} = props;

	return (
		<DatePicker
			allowClear
			value={value ? moment(value) : null}
			onChange={(v) => {
				onChange(v ? v.format('YYYY-MM-DD') : '')
			}}
			disabled={props.disabled}
		/>
	)
}
SelectDate.defaultValue = ''